/**
 * @param {number[]} nums
 * @param {number} diff
 * @return {number}
 */
var arithmeticTriplets = function (nums, diff) {
  let count = 0,
    set = new Set([...nums])
  for (let i = 0; i < nums.length - 2; i++) {
    if (set.has(nums[i] + diff) && set.has(nums[i] + 2 * diff)) count++
  }
  return count
}
